$(function(){
 	bar();
 });

function bar() {
	var echart = echarts.init(document.getElementById("bar"));
	$.ajax({
		type: "get",
		url: "dataJSON/bar.json",
		async: true,
		success: function(result) {
			var title = result.title;
			var x = result.x;
			var y = result.y;
			var option = {
				title: {
					text:'柱状图'
				},
				tooltip:{},
				legend:{
					data:title
				},
				xAxis: {
					data:x
				},
				yAxis: {},
				series: [{
					name:'销量',
					data: y,
					type: 'bar'
				}]
			};
			echart.setOption(option);
		},
		error: function() {
			layer.msg("请求服务器失败！");
		}
	});
}